Two kinds of Life Tables can be distinguished: Period tables (Table du moment) which contain for each period (here a period is a calendar year), the mortality risks at different age ranges (here, we have one year ranges) for that very period; and Tables de génération which contain for a given birthyear, the mortality risks at which an individual born during that year has been exposed.
The life tables investigated in this lab are Table du moment. According to the document by Vallin and Meslé, building the life tables required ,decisions and doctoring.
Lexis diagrams
Lexis diagrams provide a graphical device that summarizes the construction of mortality quotients (and other rates in demography).
Code
birth_dates<-as_date("1999-01-01")+duration(sample(2*365, size=20, replace=T),units="day")death_dates<-as_date("2009-07-01")+duration(sample(3*365, size=20, replace=T),units="day")b_period<-as_date("2010-01-01")b_frame<-as_date(b_period-duration(1, units ="year"))b_age<-10Ltb_ld<-tibble(birth=birth_dates, death=death_dates)tb_ld|>ggplot()+geom_segment(aes(x=b_frame, xend=death, y=interval(birth, b_frame)/years(1), yend=interval(birth, death)/years(1)))+annotate(geom="rect", xmin=b_period, xmax=as_date(b_period+duration(1, units ="year")), ymin=b_age, ymax=b_age+1L, fill="grey", alpha=.5)+ylab("Age")+xlab("Time")+coord_cartesian(xlim=c(as_date(b_period-duration(6, units ="months")), as_date(b_period+duration(18, units ="months"))), ylim=c(b_age-.5, b_age+1.5))+labs( title="A Lexis diagram", subtitle ="for mortality quotient at Age 10 during Year 2010-11")
Each line represents the life line of an individual born during years 1999 and 2000 and deceased beetween mid 2009 and mid 2012. In order to compute the mortality quotient at age 10 for year 2010, we have to compute the relevant number of occurrences, that is the number of segments ending in the grey rectangle, and the sum of exposure times, which is proportional to the sum of the lengths of the segments crossing the grey rectangle.
Definitions can be obtained from www.lifeexpectancy.org. We translate it into mathematical (rather than demographic) language.
The mortality quotients define a probability distribution over \(\mathbb{N}\). This probability distribution is a construction that reflects the health situation in a population at a given time. This probability distribution does not describe the sequence of sanitary situations experienced by a cohort (people born during a specific year).
One works with a period, or current, life table (table du moment). This summarizes the mortality experience of persons across all ages in a short period, typically one year or three years. More precisely, the death probabilities \(q_x\) for every age \(x\) are computed for that short period, often using census information gathered at regular intervals. These \(q_x\)’s are then applied to a hypothetical cohort of \(100 000\) people over their life span to produce a life table.
The table above is not as readable as it should. Use package gt to get a more tunable outpout.
Reorder and filter the columns so that Age comes first (they identify rows), then qx, mx up to ex. You can use select or relocate, or both to do this. Note that Gender, Country, Year are constant in this tibble and need to be reported in the table header, but nowhere else.
Columns qx and mx (for mortality quotient and central death rate) should be dsplayed in scientific notation so that the fact that their range extends over several orders of magnitude shows up.
Columns lx, dx, Lx, Tx contain integer values.
Column ex (residual life expectancy) is a (fictional) decimal number of years
Understanding the columns of the life table
In the sequel, we denote by \(F_{t}\) the cumulative distribution function for year \(t\). We agree on \(\overline{F}_t = 1 - F_t\) and \(F_t(-1)=0\). Henceforth, \(\overline{F}\) is called the survival function.
qx
(age-specific) risk of death at age \(x\), or mortality quotient at given age \(x\) for given year \(t\).
About the definition of q_{t,x}
Defining and computing q_{t,x} does not boil down to knowing the number of people at age \(x\) at the beginning of ear \(t\) and knowing how many of them died during year \(t\). If we want to be rigorous, we need to know all life lines in the Lexis diagram, or equivalently, how many people at Age \(x\) were alive on each day of Year \(t\).
Mortality quotients define a probability distribution
For a given year \(t\), the sequence of mortality quotients define a survival function \(\overline{F}_t\) using the following recursion:
\[q_{t,x} = \frac{\overline{F}_t(x) - \overline{F}_t(x+1)}{\overline{F}_t(x)}\] with boundary condition \(\overline{F}_t(-1) =1\).
This artificial probability distribution is used to define and compute life expectancies.
\(q_{t,x}\) is the hazard rate of \(\overline{F}_t\) at age \(x\).
mx
central death rate at age \(x\) during year \(t\). This is connected with \(q_{t,x}\) by \[m_{t,x} = -\log(1- q_{t,x}) \,,\]
or equivalently \[q_{t,x} = 1 - \exp(-m_{t,x})\]
About central death rate
If we want to define a continuous probability distribution \(G\) over \([0,\infty)\) so that \(G\) and \(F\) coincide over integers and \(G\) has piecewise constant hazard rate, we can pick \(m_{t,x}\) as the piecewise constant hazard rate.
lx
the so-called survival function: the scaled proportion of persons alive at age \(x\). These values are computed recursively from the \(q_{t,x}\) values using the formula
\[l_t(x+1) = l_t(x) \times (1-q_{t,x}) \, ,\] with \(l_{t,0}\), the radix of the table, (arbitrarily) set to \(100000\). In the table lx is rounded to the next integer
Function \(l_{t,\cdot}\) and \(\overline{F}_t\) are connected by
\(d_{t,x} = q_{t,x} \times l_{t,x}\). The fictitious number of deaths occurring at age \(x\) during year \(t\). Again this is a rounded quantity.
Tx
Total number of person-years lived by the cohort from age \(x\) to \(x+1\). This is the sum of the years lived by the \(l_{t, x+1}\) persons who survive the interval, and the \(d_{t,x}\) persons who die during the interval. The former contribute exactly \(1\) year each, while the latter contribute, on average, approximately half a year, so that \(L_{t,x} = l_{t,x+1} + 0.5 \times d_{t,x}\). This approximation assumes that deaths occur, on average, half way in the age interval x to x+1. Such is satisfactory except at age 0 and the oldest age, where other approximations are often used.
Compare with the denominator in the definition of qx and its description using the Lexis diagram.
We will stick to a simplified vision \(L_{t,x}= l_{t,x+1}\)
ex:
Residual Life Expectancy at age \(x\) and year \(t\)
This is the expectation of \(X -x\) for a random variable \(X\) distributed according to \(\overline{F}_t\) conditionnally on the event \(\{ X \geq x \}\). That is \(e_{t,x}\) is the expectation of the probability distribution defined by \(\overline{F}_t(\cdot + x-1)/\overline{F}_t(x-1)\).
Question
Check dependencies between columns
Western countries in 1948
Several pictures share a common canvas:
Question
Plot mortality quotients (qx) against age using a logarithmic scale on the \(y\) axis. Countries are identified by aesthetics (shape, color, linetype).
Use facetting to plot qx of all countries at all ages for years 1950, 1960, …, 2010.
Use plotly to build an animated plot using Year for the frame aesthetics.
Abiding to the DRY principle, define a prototype ggplot (alternatively plotly) object.
The prototype will then be fed with different datasets and decorated and arranged for the different figures.
Question
Plot ratios between mortality quotients (qx) in European countries and mortality quotients in the USA in 1948.
Comment
This animation reveals less than the preceding one since we just have ratios with respect to the USA. But the patterns followed by European societies emerge in a more transparent way. The divide between northern and southern Europe at the onset of the period is even more visible. The ratios are important across the continent: there is a factor of 10 between spanish and swedish infant mortality rates. But the ratios at ages 50 and above tend to be similar. By the early 60s, the gap between southern and northern Europe has shrinked. By now, the ratios between mortality quotients tend to be within a factor of 2 across all ages, and even less at ages 50 and above.
Death rates evolution since WW II
Question
Plot mortality quotients (column qx) for both genders as a function of Age for years 1946, 1956, ... up to 2016 . Use aesthetics to distinguish years. You will need to categorize the Year column (forcats:: may be helpful).
Facet by Gender and Country
Pay attention to axes labels, to legends. Assess logarithmic scales.
Question
Write a function ratio_mortality_rates with signature function(df, reference_year=1946, target_years=seq(1946, 2016, 10)) that takes as input:
a dataframe with the same schema as life_table,
a reference year ref_year and
a sequence of years target_years
and that returns a dataframe with schema:
Column Name
Column Type
Year
integer
Age
integer
mx
double
mx.ref_year
double
Country
factor
Gender
factor
where (Country, Year, Age, Gender) serves as a primary key, mx denotes the central death rate at Age for Year and Gender in Country whereas mx_ref_year denotes central death rate at Age for argument reference_year in Country for Gender.
Question
Draw plots displaying the ratio \(q_{x,t}/q_{x, 1946}\) for ages \(x \in 1, \ldots, 90\) and year \(t\) for \(t \in 1946, \ldots, 2013\) where \(q_{x,t}\) is the mortality quotient at age \(x\) during year \(t\).
Handle both genders and all countries
One properly facetted plot is enough.
Comment.
During the last seventy years, death rates decreased at all ages in all seven countries.This progress has not been uniform across ages, genders and countries. Across most countries, infant mortality dramatically improved during the first post-war decade while death rates at age 50 and above remained stable until the mid seventies.
Trends
We noticed that mortality quotients did not evolve in the same way across all ages: first, the decay has been much more significant at low ages; second, the decay of mortality quotients at old ages (above 60) mostly took place during the last four decades. It is worth digging separately at what happened for different parts of life.
Question
Plot mortality quotients at ages \(0, 1, 5\) as a function of time. Facet by Gender and Country
Comment
All European countries achieved the same infant mortality rates after year 2000. The USA now lag behind.
During years 1940-1945, in the Netherlands and France, gains obtained before 1940 were reversed. Year 1945 was particularly difficult in the Netherlands.
Question
Plot mortality quotients at ages \(15, 20, 40, 60\) as a function of time. Facet by Gender and Country
Comment.
While death rates at ages 15 and 20 among women are close across all societies, death rates are higher at age 20 than at age 15 among men. In France, at age 20, death rates declined from 1945 until 1960, and then increased back to their initial level until 1980. Male death rates at age 60 started to decline around 1980. Female death rates at age 60 declined steadily throughout the 7 decades. Years 1940-1945 exhibit disruptions with different shapes and intensities in Italy, France, England & Wales, and the Netherlands.